﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Web;
using EverBuy.SocialNetworking.Services;

namespace EverBuy.SocialNetworking.Client
{
    public class ServiceCollection
    {
        #region remote services members
        /// <summary>
        /// 
        /// </summary>
        public static IAccountService AccountService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["AccountService"] == null)
                    HttpContext.Current.Session["AccountService"] = new ChannelFactory<IAccountService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.AccountService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["AccountService"] as IAccountService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IAlertService AlertService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["AlertService"] == null)
                    HttpContext.Current.Session["AlertService"] = new ChannelFactory<IAlertService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.AlertService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["AlertService"] as IAlertService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IBoardService BoardService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["BoardService"] == null)
                    HttpContext.Current.Session["BoardService"] = new ChannelFactory<IBoardService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.BoardService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["BoardService"] as IBoardService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IContentFilterService ContentFilterService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["ContentFilterService"] == null)
                    HttpContext.Current.Session["ContentFilterService"] = new ChannelFactory<IContentFilterService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.ContentFilterService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["ContentFilterService"] as IContentFilterService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IFolderService FolderService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["FolderService"] == null)
                    HttpContext.Current.Session["FolderService"] = new ChannelFactory<IFolderService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.FolderService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["FolderService"] as IFolderService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IFriendService FriendService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["FriendService"] == null)
                    HttpContext.Current.Session["FriendService"] = new ChannelFactory<IFriendService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.FriendService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["FriendService"] as IFriendService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IGroupService GroupService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["GroupService"] == null)
                    HttpContext.Current.Session["GroupService"] = new ChannelFactory<IGroupService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.GroupService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["GroupService"] as IGroupService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static IMessageService MessageService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["MessageService"] == null)
                    HttpContext.Current.Session["MessageService"] = new ChannelFactory<IMessageService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.MessageService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["MessageService"] as IMessageService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static  IPrivacyService PrivacyService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["PrivacyService"] == null)
                    HttpContext.Current.Session["PrivacyService"] = new ChannelFactory<IPrivacyService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.PrivacyService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["PrivacyService"] as IPrivacyService;
            }
        }

        public static  IProfileAttributeService ProfileAttributeService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["ProfileAttributeService"] == null)
                    HttpContext.Current.Session["ProfileAttributeService"] = new ChannelFactory<IProfileAttributeService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.ProfileAttributeService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["ProfileAttributeService"] as IProfileAttributeService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static  IProfileService ProfileService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["ProfileService"] == null)
                    HttpContext.Current.Session["ProfileService"] = new ChannelFactory<IProfileService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.ProfileService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["ProfileService"] as IProfileService;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static  ITagService TagService
        {
            get
            {
                //check if not initialized yet
                if (HttpContext.Current.Session["TagService"] == null)
                    HttpContext.Current.Session["TagService"] = new ChannelFactory<ITagService>("NOIS.BottleInspectionReport.ReportServiceInterfaces.TagService.Client").CreateChannel();

                //if current client is 'faulted' (due to some error), create a new instance.
                return HttpContext.Current.Session["TagService"] as ITagService;
            }
        }
        #endregion
    }
}
